package com.hdu.point_offer;

public class lcr145 {


    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    class Solution {
        public boolean checkSymmetricTree(TreeNode root) {
            return isSame(root, root);
        }

        boolean isSame(TreeNode p, TreeNode q)
        {
            if (p == null && q == null)
            {
                return true;
            }
            if (p == null || q == null)
            {
                return false;
            }
            return p.val == q.val && isSame(p.left, q.right) && isSame(p.right, q.left);
        }
    }
}
